/*
 *  checkPoint.h
 *  opencvExample
 *
 *  Created by 真鍋 大度 on 11/03/01.
 *  Copyright 2011 Rhizomatiks. All rights reserved.
 *
 */

#pragma once
#include "ofMain.h"

class checkPoint{
public:
	void setup(int _checkPointID){
		checkPointID = _checkPointID;
		bOn = false;
		colTarget.set(0, 0, 0);	
		myBrightness = 255;
		speed = 0;
		ballID = 0;
	}
	void update(){
	}
	void draw(){
		int shiftX, textShiftX;
		
		//------right checkpoints
		if (checkPointID % 2 == 0) {
			shiftX = -80;
			textShiftX = -60;
		}
		
		//------left checkpoints
		else {
			shiftX = 80;
			textShiftX = -60;			
		}

		ofFill();
		ofSetColor(myBrightness, myBrightness, myBrightness);		
		ofRect(shiftX, 0, 10, 10);
		myBrightness = ofLerp(myBrightness, 0, 0.05);
		
		ofNoFill();
		ofSetColor(255, 0, 0);
		ofRect(shiftX, 0, 10, 10);
		
		if (bOn) {			
			ofSetColor(myBrightness, myBrightness, myBrightness);		
			ofDrawBitmapString("checkID=" + ofToString(checkPointID + 1, 0), textShiftX, -12);
			ofDrawBitmapString("ballID="  + ofToString(ballID, 0),			textShiftX, -0);		
			ofDrawBitmapString("speed="   + ofToString(speed, 2) + "msec",	textShiftX, 12);
			ofDrawBitmapString("speed="   + ofToString((int)speed*200, 3) + "msec", textShiftX, 24);		
		}

		if (myBrightness<0.05) {
			bOn = false;
		}
	}
//	void setBright
	void passing(int _ballID, float _speed){
		myBrightness = 400;
		ballID = _ballID; //ツgにアップデートするまで保持をしておく。
		speed = _speed;
		bOn = true;
		col.set(255, 255, 255);
	}
//	ofVec2f pos;
	ofColor col;
	ofColor colTarget;	
	float myBrightness;
	bool bOn;
	int ballID;
	int checkPointID;
	float speed;
	int age;
};